
#include <sys_config.h>
#include <basic_types.h>

#ifndef _AP_THAILAND_MONITOR_H_
#define _AP_THAILAND_MONITOR_H_

#define MAX_THAI_CHANNEL_LIST_SUPPORT 5
#define MAX_THAI_SERVICE_PER_LIST 1024
#define MAX_THAI_SECTION_NUM 128

typedef struct thai_section_q
{
    INT32 length;
    UINT8 *section;
}thai_section_q;
typedef struct thai_q_mng
{
    thai_section_q sections[MAX_THAI_SECTION_NUM];
    INT32 read_idx;
    INT32 write_idx;
    //INT32 count;
}thai_q_mng;

typedef struct thai_lcn_info
{
    UINT16 sid;
    UINT16 lcn;
    UINT16 visible;
}thai_lcn_info_t;

typedef struct thai_lcn_list_info
{
    UINT8 chan_list_id;
    UINT8 country_code[3];
    char list_name[256];
    thai_lcn_info_t lcn_list[MAX_THAI_SERVICE_PER_LIST];
    INT32 count;
}thai_lcn_list_info;

typedef struct thai_lcn_list
{
    UINT16 onid;
    UINT16 tsid;
    thai_lcn_list_info *plist[MAX_THAI_CHANNEL_LIST_SUPPORT];
    INT32 count;
}thai_lcn_list;

typedef struct thai_sdt_serv_info
{
    UINT16 sid;
    UINT8 service_name[2*(MAX_SERVICE_NAME_LENGTH + 1)];
    UINT8 name_len;
    UINT8 service_type;
}thai_sdt_serv_info;

typedef struct thai_sdt_serv_list
{
    thai_sdt_serv_info list[MAX_THAI_SERVICE_PER_LIST];
    UINT16 serv_count;
    UINT16 onid;
    UINT16 tsid;
}thai_sdt_serv_list;

typedef struct thai_prog_lcn_info{
    UINT16 sid;
    UINT16 lcn;
    UINT16 orig_lcn;
    UINT32 visible;
    UINT32 tp_id;
    UINT8 service_name[2*(MAX_SERVICE_NAME_LENGTH + 1)];
    UINT8 name_len;
    UINT8 av_flag;
    UINT8 hd_service;
    //Gavim
    UINT16 service_type;
    UINT16 onid;
}thai_prog_lcn_info;

typedef struct thai_prog_list
{
    thai_prog_lcn_info *list;
    INT32 count;
}thai_prog_list;

UINT32 ap_thai_nit_monitor_start(struct dmx_device *dmx);
void ap_thai_nit_monitor_stop();
UINT32 ap_thai_sdt_monitor_start(struct dmx_device *dmx);
void ap_thai_sdt_monitor_stop();
void ap_thai_monitor_msg_proc(UINT32 param1, UINT32 param2);
void ap_thai_sort_after_search();
void ap_thai_remove_one_tp_program(UINT32 tp_id);
void ap_thai_reset_unlock_tp_list();
void ap_thai_add_unlock_tp_record(UINT32 frq);
void ap_thai_remove_unlock_tp_program();

#endif //_AP_THAILAND_MONITOR_H_

